using System;
using System.Windows.Input;
using CommunityToolkit.Mvvm.Input;

namespace CANBusTools.ViewModels
{
    public class RadarControlViewModel : ViewModelBase
    {
        private readonly object _busHelper;

        private bool _isRadarOn;
        public bool IsRadarOn
        {
            get => _isRadarOn;
            set
            {
                if (_isRadarOn != value)
                {
                    _isRadarOn = value;
                    OnPropertyChanged(nameof(IsRadarOn));
                }
            }
        }

        public ICommand TurnOnCommand { get; }
        public ICommand TurnOffCommand { get; }

        public RadarControlViewModel(object busHelper)
        {
            _busHelper = busHelper;
            TurnOnCommand = new RelayCommand(TurnOnRadar);
            TurnOffCommand = new RelayCommand(TurnOffRadar);
        }

        private void TurnOnRadar()
        {
            // TODO: 替换为实际调用 _busHelper.RadarSwitch("2");
            IsRadarOn = true;
            Console.WriteLine("Radar turned ON");
        }

        private void TurnOffRadar()
        {
            // TODO: 替换为实际调用 _busHelper.RadarSwitch("1");
            IsRadarOn = false;
            Console.WriteLine("Radar turned OFF");
        }
    }
}
